<?xml version="1.0"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <property name="fileExtensions" value="java, properties, xml"/>

    <!-- Whitespaces Checks. See: http://checkstyle.sourceforge.net/config_whitespace.html -->
    <module name="FileTabCharacter">
        <property name="eachLine" value="true"/>
    </module>

    <!-- Misc Checks. See: http://checkstyle.sourceforge.net/config_misc.html -->
    <module name="NewlineAtEndOfFile"/>

    <module name="TreeWalker">
        <!-- Coding Checks. See: https://checkstyle.sourceforge.io/config_coding.html -->
        <module name="SimplifyBooleanExpression"/>

        <!-- Config Blocks. See: https://checkstyle.sourceforge.io/config_blocks.html -->
        <module name="EmptyCatchBlock">
            <property name="exceptionVariableName" value="ignore|expected"/>
        </module>

        <!-- Import Checks. See: http://checkstyle.sourceforge.net/config_imports.html -->
        <module name="RedundantImport"/>
        <module name="UnusedImports"/>
        <module name="CustomImportOrder">
            <property name="customImportOrderRules"
                      value="STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STATIC"/>
            <property name="standardPackageRegExp" value="^java\."/>
            <property name="specialImportsRegExp" value="^javax\."/>
            <property name="sortImportsInGroupAlphabetically" value="true"/>
            <property name="separateLineBetweenGroups" value="false"/>
        </module>
        <module name="AvoidStarImport"/>

        <!-- Whitespaces: See: https://checkstyle.sourceforge.io/config_whitespace.html -->
        <module name="WhitespaceAround">
            <property name="allowEmptyConstructors" value="true"/>
            <property name="allowEmptyMethods" value="true"/>
            <property name="allowEmptyTypes" value="true"/>
            <property name="allowEmptyLoops" value="true"/>
            <property name="allowEmptyLambdas" value="true"/>
            <property name="allowEmptyCatches" value="true"/>
        </module>

        <!--Modifiers Checks. See: http://checkstyle.sourceforge.net/config_modifier.html-->
        <module name="ModifierOrder"/>

        <!--Annotation checks. See: http://checkstyle.sourceforge.net/config_annotation.html-->
        <module name="MissingOverride"/>

        <!-- Empty line checks. See: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator -->
        <module name="EmptyLineSeparator">
            <!-- PACKAGE_DEF excluded according to Ignite code style. -->
            <property name="tokens" value="IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT,
                INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF" />

            <property name="allowMultipleEmptyLines" value="false" />
            <property name="allowMultipleEmptyLinesInsideClassMembers" value="false" />
        </module>

        <!-- @Override annotations on the same line with a method declaration check. -->
        <module name="AnnotationOnSameLine" />
        <module name="SuppressionXpathSingleFilter">
            <property name="checks" value="AnnotationOnSameLine" />
            <property name="query" value="//ANNOTATION[.//IDENT[not(@text='Override')]]" />
        </module>
        <!--
            Checks the padding between the identifier of a method definition, constructor definition, method call, or
            constructor invocation; and the left parenthesis of the parameter list.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#MethodParamPad
        -->
        <module name="MethodParamPad"/>

        <!--
            Checks that there is no whitespace after a token.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#NoWhitespaceAfter
        -->
        <module name="NoWhitespaceAfter">
            <property name="tokens" value="AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, ARRAY_DECLARATOR,
                INDEX_OP, METHOD_REF, TYPECAST"/>
        </module>

        <!--
            Checks that there is whitespace after a token.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#WhitespaceAfter
        -->
        <module name="WhitespaceAfter">
            <property name="tokens" value="COMMA, SEMI"/>
        </module>

        <!--
            Checks that there is no whitespace before a token.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#NoWhitespaceBefore
        -->
        <module name="NoWhitespaceBefore">
            <property name="tokens" value="COMMA, SEMI, POST_INC, POST_DEC, ELLIPSIS, METHOD_REF, GENERIC_END"/>
        </module>

        <module name="NoWhitespaceBefore">
            <property name="allowLineBreaks" value="true"/>
            <property name="tokens" value="DOT"/>
        </module>

        <!--
            Checks that non-whitespace characters are separated by no more than one whitespace.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#SingleSpaceSeparator
        -->
        <module name="SingleSpaceSeparator"/>

        <!--
            Checks that the whitespace around the Generic tokens are correct.
            See: https://checkstyle.sourceforge.io/config_whitespace.html#GenericWhitespace
        -->
        <module name="GenericWhitespace"/>

        <!--
           Checks for missing Javadoc comments for a method or constructor arguments.
           See: https://checkstyle.sourceforge.io/config_javadoc.html#MissingJavadocMethod
        -->
        <module name="MissingJavadocMethod">
            <property name="scope" value="private"/>
            <property name="allowedAnnotations" value="{}"/>
        </module>

        <!--
           Checks presence of a Javadoc for a method or constructor.
           See: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMethod
        -->
        <module name="JavadocMethod">
            <property name="accessModifiers" value="public"/>
        </module>

        <!--
           Checks for missing Javadoc comments for class, enum, interface, and annotation interface definitions.
           See: https://checkstyle.sourceforge.io/config_javadoc.html#MissingJavadocType
        -->
        <module name="MissingJavadocType">
            <property name="scope" value="private"/>
        </module>

        <!--
           Checks that a variable has a Javadoc comment. Ignores serialVersionUID fields.
           See: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocVariable
        -->
        <module name="JavadocVariable"/>

        <!--
          Suppresses MissingJavadocMethod check violations in the specified packages.
          See: https://checkstyle.sourceforge.io/config_filters.html#SuppressionXpathSingleFilter
       -->
        <module name="SuppressionXpathSingleFilter">
            <property name="checks" value="(?&lt;!Missing)JavadocMethod"/>
            <property name="files" value="[\\/]internal[\\/]|[\\/]test[\\/]|[\\/]tests[\\/]|[\\/]ml[\\/]|[\\/]yardstick[\\/]"/>
        </module>

        <!--
          Suppresses all Javadoc check violations in the specified files.
          See: https://checkstyle.sourceforge.io/config_filters.html#SuppressionXpathSingleFilter
       -->
        <module name="SuppressionXpathSingleFilter">
            <property name="checks" value="Javadoc"/>
            <property name="files" value="BCrypt\.java|HLL\.java|HLLMetadata\.java|HLLType\.java|BigEndianAscendingWordSerializer\.java|NumberUtil\.java|SchemaVersionOne\.java|BigEndianAscendingWordDeserializer\.java|CacheView\.java|ConcurrentLinkedDeque8\.java|ConcurrentHashMap8\.java|ConcurrentLinkedHashMap\.java"/>
        </module>

        <module name="Indentation" />

        <module name="LeftCurly"/>

        <module name="RightCurly">
            <property name="option" value="alone" />
        </module>

        <!-- Usage of Ignite abbrevations check. -->
        <module name="org.apache.ignite.tools.checkstyle.IgniteAbbrevationsRule"/>
    </module>

    <!--
        Checks that the line length not exceeds 140 chars.
        See: https://checkstyle.org/config_sizes.html#LineLength
    -->
    <module name="LineLength">
        <property name="max" value="140"/>
    </module>
</module>
